package com.payment.ktb.activity;

import android.os.Bundle;
import android.view.View;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.LinearLayout;

import com.payment.ktb.R;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by syd on 2016/8/2.
 */
public class ShowH5WithTitleActivity extends BaseActivity {

    @BindView(R.id.wv_showh5withtitle)
    WebView wv_showh5withtitle;
    @BindView(R.id.ll_title_back)
    LinearLayout ll_title_back;


    String url;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_showh5withtitle);
        ButterKnife.bind(this);
        initTitle(getIntent().getStringExtra("title"));
        url = getIntent().getStringExtra("url");
        wv_showh5withtitle.loadUrl(url);
        //支持js
        wv_showh5withtitle.getSettings().setJavaScriptEnabled(true);
        //解决显示不全的问题
        wv_showh5withtitle.getSettings().setDomStorageEnabled(true);
        wv_showh5withtitle.setWebViewClient(new HelloWebViewClient ());

        if ("StartAdvertisementActivity".equals(getIntent().getStringExtra("fromActivity")) || "CashierUnionOnlineActivity".equals(getIntent().getStringExtra("fromActivity")) ) {
            ll_title_back.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    startActivity(MainActivity.class);
                }
            });
        }

    }



    private class HelloWebViewClient extends WebViewClient {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
        }
    }




}
